{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "10143c26",
   "metadata": {},
   "source": [
    "# 财务数据与因子分析策略2-多因子策略介绍"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b739fd4",
   "metadata": {},
   "source": [
    "## 简单因子相关性\n",
    "\n",
    "* classwork 1\n",
    "\n",
    "把上节课，简单多因子分析方法所有代码简化并整理到一起。然后修改参数尝试分析其他财务因子。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "49c355cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.stats.mstats import winsorize\n",
    "from scipy.stats import pearsonr,spearmanr,kendalltau\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from gm.api import *\n",
    "set_token(\"eea4b28a3ceb7048603d388bb777ebc67de47385\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "262f884f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ROEANNUALs SpearmanrResult(correlation=-0.06365697164615212, pvalue=0.3633436720873816)\n",
      "NPGRTs SpearmanrResult(correlation=-0.03908868572571857, pvalue=0.5769621153584988)\n",
      "OPNCFPSs SpearmanrResult(correlation=0.11837676919698044, pvalue=0.09014156644234972)\n"
     ]
    }
   ],
   "source": [
    "def standardize_series(series):#标准化\n",
    "    std = series.std()\n",
    "    mean = series.mean()\n",
    "    return (series-mean)/std\n",
    "\n",
    "index_s='SHSE.000300'\n",
    "table_s='deriv_finance_indicator'\n",
    "#'trading_derivative_indicator'\n",
    "start_date_s='2016-01-01'\n",
    "end_date_s='2016-06-01'\n",
    "fields_s='ROEANNUAL,NPGRT,OPNCFPS'\n",
    "#'TCLOSE,NEGOTIABLEMV,TOTMKTCAP,TURNRATE,PELFY,PETTM,PEMRQ,PELFYNPAAEI,PETTMNPAAEI'\n",
    "\n",
    "hs300=get_constituents(index=index_s, fields='symbol, weight', df=True)\n",
    "ex2=get_fundamentals(table=table_s, symbols=hs300.symbol.tolist(), start_date=start_date_s, end_date=end_date_s,\n",
    "                 fields=fields_s, df=True,limit=40000)\n",
    "ex3=ex2.set_index([\"end_date\",\"symbol\"])\n",
    "\n",
    "history_data=history(symbol=hs300.symbol.tolist(), frequency='1d', start_time=start_date_s,  end_time=end_date_s, fields='symbol,close,eob', adjust=ADJUST_PREV, df= True)\n",
    "history_data_n=history_data.set_index([\"eob\",\"symbol\"]).unstack().close\n",
    "history_data_p=history_data_n/history_data_n.shift(1)-1\n",
    "\n",
    "h_m=history_data_p.shift(-1).stack()\n",
    "\n",
    "col=[]\n",
    "for i in ex3.columns[1:]:\n",
    "    z1=winsorize(ex3[i],limits=0.03)\n",
    "    col.append(i+\"s\")\n",
    "    ex3[i+\"s\"]=standardize_series(z1)\n",
    "    \n",
    "    \n",
    "f_y_1=pd.concat([h_m,ex3],axis=1).dropna()\n",
    "\n",
    "for i in col:\n",
    "    print(i,spearmanr(f_y_1.iloc[:,0],f_y_1[i]))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "328d56df",
   "metadata": {},
   "source": [
    "## 单因子策略框架\n",
    "\n",
    "\n",
    "### classwork 2\n",
    "* 小市值策略“TOTMKTCAP”\n",
    "* 策略运行时间2013-01-01到2014-12-30\n",
    "\n",
    "https://www.bilibili.com/video/BV1uq4y177uX/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "404543e8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "792b7edb",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7e2ec1a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import timedelta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "253705fa",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'context' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_15500/232826787.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;33m(\u001b[0m\u001b[0mcontext\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnow\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mtimedelta\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdays\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m100\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrftime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"%Y-%m-%d %H:%M:%S\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'context' is not defined"
     ]
    }
   ],
   "source": [
    "# 获取筛选时间：date1表示当前日期之前的100天，date2表示当前时间\n",
    "date1 = (context.now - timedelta(days=100)).strftime(\"%Y-%m-%d %H:%M:%S\")\n",
    "date2 = context.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n",
    "\n",
    "# 通过get_instruments获取所有的上市股票代码\n",
    "all_stock = get_instruments(exchanges='SHSE, SZSE', sec_types=[1], fields='symbol, listed_date, delisted_date',\n",
    "                            df=True)\n",
    "\n",
    "# 剔除停牌和st股和上市不足100日的新股和退市股和B股\n",
    "code = all_stock[(all_stock['listed_date'] < date1) & (all_stock['delisted_date'] > date2) &\n",
    "                 (all_stock['symbol'].str[5] != '9') & (all_stock['symbol'].str[5] != '2')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "53464f34",
   "metadata": {},
   "outputs": [],
   "source": [
    "cw_data=get_fundamentals_n(table='trading_derivative_indicator', symbols=hs300.symbol.tolist(), end_date=\"2016-01-01\", count=1,\n",
    "               fields='TOTMKTCAP',df=True)\n",
    "to_buy=cw_data.sort_values(by=\"TOTMKTCAP\",ascending=False).head(10).symbol.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a4c4a55a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>symbol</th>\n",
       "      <th>pub_date</th>\n",
       "      <th>end_date</th>\n",
       "      <th>TOTMKTCAP</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>SZSE.002352</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>3.7370e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>SZSE.002120</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>4.0500e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>212</th>\n",
       "      <td>SHSE.600760</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>5.3328e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>174</th>\n",
       "      <td>SZSE.000708</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>5.4873e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>SZSE.002607</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>5.6038e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>SHSE.601628</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>5.8951e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>SHSE.601988</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>8.4517e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>SHSE.601288</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>9.4980e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>SHSE.601398</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>1.2348e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>SHSE.601857</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>2015-12-31 00:00:00+08:00</td>\n",
       "      <td>1.3520e+12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>223 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          symbol                  pub_date                  end_date  \\\n",
       "55   SZSE.002352 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "30   SZSE.002120 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "212  SHSE.600760 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "174  SZSE.000708 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "82   SZSE.002607 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "..           ...                       ...                       ...   \n",
       "50   SHSE.601628 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "94   SHSE.601988 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "5    SHSE.601288 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "31   SHSE.601398 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "72   SHSE.601857 2015-12-31 00:00:00+08:00 2015-12-31 00:00:00+08:00   \n",
       "\n",
       "      TOTMKTCAP  \n",
       "55   3.7370e+09  \n",
       "30   4.0500e+09  \n",
       "212  5.3328e+09  \n",
       "174  5.4873e+09  \n",
       "82   5.6038e+09  \n",
       "..          ...  \n",
       "50   5.8951e+11  \n",
       "94   8.4517e+11  \n",
       "5    9.4980e+11  \n",
       "31   1.2348e+12  \n",
       "72   1.3520e+12  \n",
       "\n",
       "[223 rows x 4 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cw_data.sort_values(by=\"TOTMKTCAP\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8958b3cb",
   "metadata": {},
   "source": [
    "## 多因子策略框架\n",
    "\n",
    "伟文同学的因子：表：'deriv_finance_indicator'   此三因子'ROEANNUAL,NPGRT,OPNCFPS' 最大的\n",
    "\n",
    "get_fundamentals_n\n",
    "\n",
    "set_index\n",
    "\n",
    "sort_values\n",
    "\n",
    "\n",
    "ROEANNUAL\t年化净资产收益率\t%\t净资产收益率＊12/报告期所占月数\n",
    "\n",
    "NPGRT\t归属母公司净利润增长率\n",
    "\n",
    "OPNCFPS\t每股经营活动产生的现金流量净额\n",
    "\n",
    "### classwork 3\n",
    "\n",
    "* 通过get_fundamentals_n获取2020-01-01最近一期的沪深300的'ROEANNUAL,NPGRT,OPNCFPS'，然后分别对此三个因子排序，以排序序号作为加权因子，选择三因子加权求和得到最大的前10只股票\n",
    "\n",
    "* 在掘金中实现以上策略，时间选择2020-01-01到2021-12-30， 选股周期为1个月"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "17ed88b1",
   "metadata": {},
   "outputs": [],
   "source": [
    "index_s='SHSE.000300'\n",
    "hs300=get_constituents(index=index_s, fields='symbol, weight', df=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72f79d5c",
   "metadata": {},
   "outputs": [],
   "source": [
    "ex2=get_fundamentals(table=table_s, symbols=hs300.symbol.tolist(), start_date=start_date_s, end_date=end_date_s,\n",
    "                 fields=fields_s, df=True,limit=40000)\n",
    "ex3=ex2.set_index([\"end_date\",\"symbol\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "81e3cd15",
   "metadata": {},
   "outputs": [],
   "source": [
    "cw_data=get_fundamentals_n(table='deriv_finance_indicator', symbols=hs300.symbol.tolist(), end_date=\"2020-01-01\", count=1,\n",
    "                            fields='ROEANNUAL,NPGRT,OPNCFPS',df=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "01d51d5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "cw_data.set_index(\"symbol\",inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "866a0457",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pub_date</th>\n",
       "      <th>end_date</th>\n",
       "      <th>ROEANNUAL</th>\n",
       "      <th>NPGRT</th>\n",
       "      <th>OPNCFPS</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>SZSE.002236</th>\n",
       "      <td>2020-04-03 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>22.5615</td>\n",
       "      <td>26.0422</td>\n",
       "      <td>0.5329</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002241</th>\n",
       "      <td>2020-04-17 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>8.1802</td>\n",
       "      <td>47.5751</td>\n",
       "      <td>1.6799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.601618</th>\n",
       "      <td>2020-04-01 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>9.4252</td>\n",
       "      <td>3.5805</td>\n",
       "      <td>0.8482</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002252</th>\n",
       "      <td>2020-04-25 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>5.4382</td>\n",
       "      <td>140.0352</td>\n",
       "      <td>0.1754</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.300628</th>\n",
       "      <td>2020-04-15 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>31.2919</td>\n",
       "      <td>45.0767</td>\n",
       "      <td>1.8225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.600999</th>\n",
       "      <td>2020-03-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>10.7274</td>\n",
       "      <td>64.5741</td>\n",
       "      <td>1.4910</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002230</th>\n",
       "      <td>2020-04-22 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>8.4499</td>\n",
       "      <td>51.1211</td>\n",
       "      <td>0.6966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.300558</th>\n",
       "      <td>2020-04-21 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>9.9315</td>\n",
       "      <td>38.3670</td>\n",
       "      <td>1.3842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.601607</th>\n",
       "      <td>2020-03-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>10.1174</td>\n",
       "      <td>5.1514</td>\n",
       "      <td>2.1190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002179</th>\n",
       "      <td>2020-03-31 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>15.3654</td>\n",
       "      <td>12.5610</td>\n",
       "      <td>0.7679</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                             pub_date                  end_date  ROEANNUAL  \\\n",
       "symbol                                                                       \n",
       "SZSE.002236 2020-04-03 00:00:00+08:00 2019-12-31 00:00:00+08:00    22.5615   \n",
       "SZSE.002241 2020-04-17 00:00:00+08:00 2019-12-31 00:00:00+08:00     8.1802   \n",
       "SHSE.601618 2020-04-01 00:00:00+08:00 2019-12-31 00:00:00+08:00     9.4252   \n",
       "SZSE.002252 2020-04-25 00:00:00+08:00 2019-12-31 00:00:00+08:00     5.4382   \n",
       "SZSE.300628 2020-04-15 00:00:00+08:00 2019-12-31 00:00:00+08:00    31.2919   \n",
       "...                               ...                       ...        ...   \n",
       "SHSE.600999 2020-03-28 00:00:00+08:00 2019-12-31 00:00:00+08:00    10.7274   \n",
       "SZSE.002230 2020-04-22 00:00:00+08:00 2019-12-31 00:00:00+08:00     8.4499   \n",
       "SZSE.300558 2020-04-21 00:00:00+08:00 2019-12-31 00:00:00+08:00     9.9315   \n",
       "SHSE.601607 2020-03-28 00:00:00+08:00 2019-12-31 00:00:00+08:00    10.1174   \n",
       "SZSE.002179 2020-03-31 00:00:00+08:00 2019-12-31 00:00:00+08:00    15.3654   \n",
       "\n",
       "                NPGRT  OPNCFPS  \n",
       "symbol                          \n",
       "SZSE.002236   26.0422   0.5329  \n",
       "SZSE.002241   47.5751   1.6799  \n",
       "SHSE.601618    3.5805   0.8482  \n",
       "SZSE.002252  140.0352   0.1754  \n",
       "SZSE.300628   45.0767   1.8225  \n",
       "...               ...      ...  \n",
       "SHSE.600999   64.5741   1.4910  \n",
       "SZSE.002230   51.1211   0.6966  \n",
       "SZSE.300558   38.3670   1.3842  \n",
       "SHSE.601607    5.1514   2.1190  \n",
       "SZSE.002179   12.5610   0.7679  \n",
       "\n",
       "[300 rows x 5 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cw_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b6fc8eea",
   "metadata": {},
   "outputs": [],
   "source": [
    "f_r=cw_data.sort_values(\"ROEANNUAL\",ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "4aa44c25",
   "metadata": {},
   "outputs": [],
   "source": [
    "f_r[\"rs\"]=list(range(1,len(f_r)+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0b7a3989",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "symbol\n",
       "SHSE.688169      1\n",
       "SHSE.600132      2\n",
       "SZSE.300896      3\n",
       "SZSE.002607      4\n",
       "SHSE.603195      5\n",
       "              ... \n",
       "SHSE.688126    296\n",
       "SZSE.000625    297\n",
       "SHSE.688561    298\n",
       "SZSE.002044    299\n",
       "SZSE.002466    300\n",
       "Name: rs, Length: 300, dtype: int64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f_r[\"rs\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "7c44c09e",
   "metadata": {},
   "outputs": [],
   "source": [
    "f_n=cw_data.sort_values(\"NPGRT\",ascending=False)\n",
    "f_n[\"ns\"]=list(range(1,len(f_n)+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "2ef987c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "f_o=cw_data.sort_values(\"OPNCFPS\",ascending=False)\n",
    "f_o[\"os\"]=list(range(1,len(f_o)+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "01a3b83f",
   "metadata": {},
   "outputs": [],
   "source": [
    "fz=f_r[\"rs\"]+f_n[\"ns\"]+f_o[\"os\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d2fb705f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "symbol\n",
       "SHSE.688169     31\n",
       "SHSE.603160     40\n",
       "SZSE.002714     42\n",
       "SHSE.600132     57\n",
       "SHSE.688036     73\n",
       "              ... \n",
       "SHSE.688126    834\n",
       "SZSE.300142    848\n",
       "SZSE.002044    849\n",
       "SHSE.600010    855\n",
       "SZSE.002709    866\n",
       "Length: 300, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fz.sort_values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "42ebe98c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['SHSE.688169',\n",
       " 'SHSE.603160',\n",
       " 'SZSE.002714',\n",
       " 'SHSE.600132',\n",
       " 'SHSE.688036',\n",
       " 'SZSE.300896',\n",
       " 'SZSE.300498',\n",
       " 'SHSE.605499',\n",
       " 'SZSE.000661',\n",
       " 'SHSE.600346']"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fz.sort_values().head(10).index.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "169b120b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pub_date</th>\n",
       "      <th>end_date</th>\n",
       "      <th>ROEANNUAL</th>\n",
       "      <th>NPGRT</th>\n",
       "      <th>OPNCFPS</th>\n",
       "      <th>rs</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>SHSE.688169</th>\n",
       "      <td>2020-04-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>71.6893</td>\n",
       "      <td>154.5155</td>\n",
       "      <td>15.1095</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.600132</th>\n",
       "      <td>2020-04-18 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>58.6297</td>\n",
       "      <td>158.1524</td>\n",
       "      <td>4.2360</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.300896</th>\n",
       "      <td>2020-06-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>57.7899</td>\n",
       "      <td>148.6836</td>\n",
       "      <td>3.4413</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002607</th>\n",
       "      <td>2020-03-10 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>56.5202</td>\n",
       "      <td>56.5243</td>\n",
       "      <td>0.4011</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.603195</th>\n",
       "      <td>2020-04-27 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>52.3640</td>\n",
       "      <td>37.3829</td>\n",
       "      <td>4.2543</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.688126</th>\n",
       "      <td>2020-03-31 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-2.1263</td>\n",
       "      <td>-902.3971</td>\n",
       "      <td>0.4767</td>\n",
       "      <td>296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.000625</th>\n",
       "      <td>2020-04-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-5.8638</td>\n",
       "      <td>-488.8069</td>\n",
       "      <td>0.8083</td>\n",
       "      <td>297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.688561</th>\n",
       "      <td>2020-05-11 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-10.6215</td>\n",
       "      <td>43.2246</td>\n",
       "      <td>-1.9283</td>\n",
       "      <td>298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002044</th>\n",
       "      <td>2020-04-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-12.4836</td>\n",
       "      <td>-205.5841</td>\n",
       "      <td>0.3213</td>\n",
       "      <td>299</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002466</th>\n",
       "      <td>2020-04-29 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-69.9844</td>\n",
       "      <td>-371.9572</td>\n",
       "      <td>1.5943</td>\n",
       "      <td>300</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                             pub_date                  end_date  ROEANNUAL  \\\n",
       "symbol                                                                       \n",
       "SHSE.688169 2020-04-28 00:00:00+08:00 2019-12-31 00:00:00+08:00    71.6893   \n",
       "SHSE.600132 2020-04-18 00:00:00+08:00 2019-12-31 00:00:00+08:00    58.6297   \n",
       "SZSE.300896 2020-06-30 00:00:00+08:00 2019-12-31 00:00:00+08:00    57.7899   \n",
       "SZSE.002607 2020-03-10 00:00:00+08:00 2019-12-31 00:00:00+08:00    56.5202   \n",
       "SHSE.603195 2020-04-27 00:00:00+08:00 2019-12-31 00:00:00+08:00    52.3640   \n",
       "...                               ...                       ...        ...   \n",
       "SHSE.688126 2020-03-31 00:00:00+08:00 2019-12-31 00:00:00+08:00    -2.1263   \n",
       "SZSE.000625 2020-04-30 00:00:00+08:00 2019-12-31 00:00:00+08:00    -5.8638   \n",
       "SHSE.688561 2020-05-11 00:00:00+08:00 2019-12-31 00:00:00+08:00   -10.6215   \n",
       "SZSE.002044 2020-04-30 00:00:00+08:00 2019-12-31 00:00:00+08:00   -12.4836   \n",
       "SZSE.002466 2020-04-29 00:00:00+08:00 2019-12-31 00:00:00+08:00   -69.9844   \n",
       "\n",
       "                NPGRT  OPNCFPS   rs  \n",
       "symbol                               \n",
       "SHSE.688169  154.5155  15.1095    1  \n",
       "SHSE.600132  158.1524   4.2360    2  \n",
       "SZSE.300896  148.6836   3.4413    3  \n",
       "SZSE.002607   56.5243   0.4011    4  \n",
       "SHSE.603195   37.3829   4.2543    5  \n",
       "...               ...      ...  ...  \n",
       "SHSE.688126 -902.3971   0.4767  296  \n",
       "SZSE.000625 -488.8069   0.8083  297  \n",
       "SHSE.688561   43.2246  -1.9283  298  \n",
       "SZSE.002044 -205.5841   0.3213  299  \n",
       "SZSE.002466 -371.9572   1.5943  300  \n",
       "\n",
       "[300 rows x 6 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f_r=cw_data.sort_values(\"ROEANNUAL\",ascending=False)\n",
    "f_r[\"rs\"]=list(range(1,len(f_r)+1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "04a43a34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>symbol</th>\n",
       "      <th>pub_date</th>\n",
       "      <th>end_date</th>\n",
       "      <th>ROEANNUAL</th>\n",
       "      <th>NPGRT</th>\n",
       "      <th>OPNCFPS</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SHSE.601966</td>\n",
       "      <td>2020-04-14 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>16.2787</td>\n",
       "      <td>41.2040</td>\n",
       "      <td>2.3332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>SZSE.002594</td>\n",
       "      <td>2020-04-22 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>3.1146</td>\n",
       "      <td>-41.9303</td>\n",
       "      <td>5.4033</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>SHSE.688036</td>\n",
       "      <td>2020-04-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>29.4702</td>\n",
       "      <td>172.7963</td>\n",
       "      <td>5.0506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>SHSE.603019</td>\n",
       "      <td>2020-03-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>15.1879</td>\n",
       "      <td>37.8603</td>\n",
       "      <td>3.5252</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SHSE.601985</td>\n",
       "      <td>2020-04-24 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>9.7984</td>\n",
       "      <td>0.4380</td>\n",
       "      <td>1.7131</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>295</th>\n",
       "      <td>SHSE.688009</td>\n",
       "      <td>2020-03-26 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>11.8454</td>\n",
       "      <td>11.9502</td>\n",
       "      <td>0.3184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>296</th>\n",
       "      <td>SZSE.002568</td>\n",
       "      <td>2020-03-31 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>15.3137</td>\n",
       "      <td>142.6697</td>\n",
       "      <td>1.0206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>297</th>\n",
       "      <td>SZSE.002624</td>\n",
       "      <td>2020-04-24 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>16.7407</td>\n",
       "      <td>-11.9163</td>\n",
       "      <td>1.5647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>SHSE.601898</td>\n",
       "      <td>2020-03-21 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>5.9465</td>\n",
       "      <td>67.8984</td>\n",
       "      <td>1.6578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>299</th>\n",
       "      <td>SHSE.601899</td>\n",
       "      <td>2020-03-21 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>10.4908</td>\n",
       "      <td>4.6457</td>\n",
       "      <td>0.4203</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          symbol                  pub_date                  end_date  \\\n",
       "0    SHSE.601966 2020-04-14 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "1    SZSE.002594 2020-04-22 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "2    SHSE.688036 2020-04-28 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "3    SHSE.603019 2020-03-28 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "4    SHSE.601985 2020-04-24 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "..           ...                       ...                       ...   \n",
       "295  SHSE.688009 2020-03-26 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "296  SZSE.002568 2020-03-31 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "297  SZSE.002624 2020-04-24 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "298  SHSE.601898 2020-03-21 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "299  SHSE.601899 2020-03-21 00:00:00+08:00 2019-12-31 00:00:00+08:00   \n",
       "\n",
       "     ROEANNUAL     NPGRT  OPNCFPS  \n",
       "0      16.2787   41.2040   2.3332  \n",
       "1       3.1146  -41.9303   5.4033  \n",
       "2      29.4702  172.7963   5.0506  \n",
       "3      15.1879   37.8603   3.5252  \n",
       "4       9.7984    0.4380   1.7131  \n",
       "..         ...       ...      ...  \n",
       "295    11.8454   11.9502   0.3184  \n",
       "296    15.3137  142.6697   1.0206  \n",
       "297    16.7407  -11.9163   1.5647  \n",
       "298     5.9465   67.8984   1.6578  \n",
       "299    10.4908    4.6457   0.4203  \n",
       "\n",
       "[300 rows x 6 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "5fd1f96f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pub_date</th>\n",
       "      <th>end_date</th>\n",
       "      <th>ROEANNUAL</th>\n",
       "      <th>NPGRT</th>\n",
       "      <th>OPNCFPS</th>\n",
       "      <th>s1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>SZSE.002466</th>\n",
       "      <td>2020-04-29 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-69.9844</td>\n",
       "      <td>-371.9572</td>\n",
       "      <td>1.5943</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002044</th>\n",
       "      <td>2020-04-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-12.4836</td>\n",
       "      <td>-205.5841</td>\n",
       "      <td>0.3213</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.688561</th>\n",
       "      <td>2020-05-11 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-10.6215</td>\n",
       "      <td>43.2246</td>\n",
       "      <td>-1.9283</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.000625</th>\n",
       "      <td>2020-04-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-5.8638</td>\n",
       "      <td>-488.8069</td>\n",
       "      <td>0.8083</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.688126</th>\n",
       "      <td>2020-03-31 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>-2.1263</td>\n",
       "      <td>-902.3971</td>\n",
       "      <td>0.4767</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.603195</th>\n",
       "      <td>2020-04-27 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>52.3640</td>\n",
       "      <td>37.3829</td>\n",
       "      <td>4.2543</td>\n",
       "      <td>296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.002607</th>\n",
       "      <td>2020-03-10 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>56.5202</td>\n",
       "      <td>56.5243</td>\n",
       "      <td>0.4011</td>\n",
       "      <td>297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SZSE.300896</th>\n",
       "      <td>2020-06-30 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>57.7899</td>\n",
       "      <td>148.6836</td>\n",
       "      <td>3.4413</td>\n",
       "      <td>298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.600132</th>\n",
       "      <td>2020-04-18 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>58.6297</td>\n",
       "      <td>158.1524</td>\n",
       "      <td>4.2360</td>\n",
       "      <td>299</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SHSE.688169</th>\n",
       "      <td>2020-04-28 00:00:00+08:00</td>\n",
       "      <td>2019-12-31 00:00:00+08:00</td>\n",
       "      <td>71.6893</td>\n",
       "      <td>154.5155</td>\n",
       "      <td>15.1095</td>\n",
       "      <td>300</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>300 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                             pub_date                  end_date  ROEANNUAL  \\\n",
       "symbol                                                                       \n",
       "SZSE.002466 2020-04-29 00:00:00+08:00 2019-12-31 00:00:00+08:00   -69.9844   \n",
       "SZSE.002044 2020-04-30 00:00:00+08:00 2019-12-31 00:00:00+08:00   -12.4836   \n",
       "SHSE.688561 2020-05-11 00:00:00+08:00 2019-12-31 00:00:00+08:00   -10.6215   \n",
       "SZSE.000625 2020-04-30 00:00:00+08:00 2019-12-31 00:00:00+08:00    -5.8638   \n",
       "SHSE.688126 2020-03-31 00:00:00+08:00 2019-12-31 00:00:00+08:00    -2.1263   \n",
       "...                               ...                       ...        ...   \n",
       "SHSE.603195 2020-04-27 00:00:00+08:00 2019-12-31 00:00:00+08:00    52.3640   \n",
       "SZSE.002607 2020-03-10 00:00:00+08:00 2019-12-31 00:00:00+08:00    56.5202   \n",
       "SZSE.300896 2020-06-30 00:00:00+08:00 2019-12-31 00:00:00+08:00    57.7899   \n",
       "SHSE.600132 2020-04-18 00:00:00+08:00 2019-12-31 00:00:00+08:00    58.6297   \n",
       "SHSE.688169 2020-04-28 00:00:00+08:00 2019-12-31 00:00:00+08:00    71.6893   \n",
       "\n",
       "                NPGRT  OPNCFPS   s1  \n",
       "symbol                               \n",
       "SZSE.002466 -371.9572   1.5943    1  \n",
       "SZSE.002044 -205.5841   0.3213    2  \n",
       "SHSE.688561   43.2246  -1.9283    3  \n",
       "SZSE.000625 -488.8069   0.8083    4  \n",
       "SHSE.688126 -902.3971   0.4767    5  \n",
       "...               ...      ...  ...  \n",
       "SHSE.603195   37.3829   4.2543  296  \n",
       "SZSE.002607   56.5243   0.4011  297  \n",
       "SZSE.300896  148.6836   3.4413  298  \n",
       "SHSE.600132  158.1524   4.2360  299  \n",
       "SHSE.688169  154.5155  15.1095  300  \n",
       "\n",
       "[300 rows x 6 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "682d07e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['SHSE.688169', 'SHSE.603160', 'SZSE.002714', 'SHSE.600132',\n",
       "       'SHSE.688036', 'SZSE.300896', 'SZSE.300498', 'SHSE.605499',\n",
       "       'SZSE.000661', 'SHSE.600346'],\n",
       "      dtype='object', name='symbol')"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "354aad58",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c5c9fb7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
